﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="tur2List", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Tur2List))]
    public class Tur2ListSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ITur2List clazz;
        
        public Tur2ListSerializer(ITur2List clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            for (int x = 0; ((clazz.Tur2 != null) 
                        && (x < clazz.Tur2.Count)); x = (x + 1)) {
                if (clazz.Tur2[x]!=null) {
                    Writer.WriteStartElement("tur2");
                    global::Xtee.Core.SerializationMetadata metaTur2 = this.GetMetaData(clazz.Tur2[x]);
                    Writer.WriteTypeAttribute(metaTur2.TypeQualifiedName.Namespace, metaTur2.TypeQualifiedName.Name);
                    metaTur2.NewSerializer(clazz.Tur2[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="tur2") {
                clazz.Tur2 = new System.Collections.Generic.List<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.ITur2>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "tur2")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tur2List>tur2");
                    }
                    global::Xtee.Core.SerializationMetadata metaTur2 = this.GetMetaData<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.ITur2>(Reader, "tur2", "http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000");
                    global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.ITur2 item = metaTur2.NewEntity<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.ITur2>();
                    clazz.Tur2.Add(item);
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("tur2");
                        metaTur2.NewSerializer(item).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
            }
        }
    }
}
